#include "StdAfx.h"
#include "HBCurlThreadMgr.h"
#include "HBCurl.h"


CHBDownLoadThreadWorkor::CHBDownLoadThreadWorkor( const string& sUrl, const string& sLocalPath, int iStartPos, int iEndPos, 
	int iFileSize, const string& sUserPwd, CHBLoadItemMgr* pLoadItemMgr, bool bPreCreateFile /*= true*/ )
	: m_sUrl(sUrl)
	, m_sLocalPath(sLocalPath)
	, m_iStartPos(iStartPos)
	, m_iEndPos(iEndPos)
	, m_iFileSize(iFileSize)
	, m_sUserPwd(sUserPwd)
	, m_pLoadItemMgr(pLoadItemMgr)
	, m_bPreCreateFile(bPreCreateFile)
{
}

long CHBDownLoadThreadWorkor::Execute()
{
	return (CHBEasyCurl::DownloadFile(m_sUrl, m_sLocalPath, m_iStartPos, m_iEndPos, 
		m_iFileSize, m_sUserPwd, m_pLoadItemMgr, m_bPreCreateFile, true) ? 0 : 1);
}
///
CHBFtpUpLoadThreadWorkor::CHBFtpUpLoadThreadWorkor( const string& sUrl, const string& sLocalPath, const string& sUserPwd,
	CHBLoadItemMgr* pLoadItemMgr )
	: m_sUrl(sUrl)
	, m_sLocalPath(sLocalPath)
	, m_sUserPwd(sUserPwd)
	, m_pLoadItemMgr(pLoadItemMgr)

{

}

long CHBFtpUpLoadThreadWorkor::Execute()
{
	return (CHBEasyCurl::UploadFile(m_sUrl, m_sLocalPath, m_sUserPwd, m_pLoadItemMgr, true) ? 0 : 1);
}
//////////////////////////////////////////////////////////////////////////
CHBCurlThreadPool::CHBCurlThreadPool()
{
	bool bCreate = Create(100);
}

CHBCurlThreadPool::~CHBCurlThreadPool()
{

}

CHBCurlThreadPool& CHBCurlThreadPool::instance()
{
	static CHBCurlThreadPool inst;
	return inst;
}
